package net.danielseidl.ludumdare.ld48.character;

import net.danielseidl.ludumdare.ld48.level.Level;

/**
 * Representation of a player character.
 *
 * @author    Daniel Seidl - info@daniel-seidl.net
 */
public class Player extends Character
	{
	private int life_cur;
	private int life_max;
	
	/**
	 * Creates a new player.
	 * @param level The level instance to use.
	 */
	public Player(Level level)
		{
		// TODO -> just for testing at the moment!
		super(new int[]{35, 35, 30, 15}, level, SpeedType.MEDIUM, "player");
		
		this.life_max = 12;
		this.life_cur = this.life_max;
		}
	
	public int getLifeCur()
		{
		return this.life_cur;
		}
	
	public int getLifeMax()
		{
		return this.life_max;
		}
	
	/**
	 * Moves the player on the map using the given speed of the player.
	 * @param md The direction to move to.
	 * @returns true if the player is now in another tile.
	 */
	public boolean movePlayer(MoveDirection md)
		{
		boolean ret = this.moveCharacter(md);
		
		// Check if the player has escaped this level.		
		if (this.isCharAtTile(this.level.getLevelExitLocation()))
			{
			this.game.playerHasEscaped();
			}
		
		return ret;
		}
	
	/**
	 * Sets the level to the given level.
	 * @param level The level to set to.
	 */
	public void setLevel(Level level)
		{
		this.level = level;
		}
	}